package com.sinopec.handdevice.view

import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.jakewharton.rxbinding3.view.clicks
import com.sinopec.basemodule.base.BaseFragment
import com.sinopec.basemodule.base.BasePresenter
import com.sinopec.basemodule.launchcontract.UHFDailyInventoryResultLaunch
import com.sinopec.basemodule.model.PackSpecsTypeModel
import com.sinopec.basemodule.utils.ARouterManagerUtils
import com.sinopec.handdevice.R
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.android.synthetic.main.fragment_user.*
import java.util.concurrent.TimeUnit

/**
 * @author lwj
 * @ClassName: MineFragment
 * @Description:我的主界面
 */
@Route(path = ARouterManagerUtils.GOTO_MAIN_MINE_FRAGMENT)
class MineFragment : BaseFragment<BasePresenter>() {

    /**
     * 日常盘库扫码启动器
     */
    private val uhfDailyInventoryLauncher by lazy {
        registerForActivityResult(UHFDailyInventoryResultLaunch) {}
    }

    override fun initView(view: View) {

    }

    override fun getLayoutId(): Int {
        return R.layout.fragment_user
    }

    override fun initEvent() {
        super.initEvent()

        /**
         * 日常盘库扫码启动器
         */
        uhfDailyInventoryLauncher

        /**
         * 设置
         */
        addDisposable(ll_set
            .clicks()
            .throttleFirst(1, TimeUnit.SECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                ARouterManagerUtils.gotoUhfSetScan()
            })

        /**
         * 日常盘库
         */
        addDisposable(ll_inventory
            .clicks()
            .throttleFirst(1, TimeUnit.SECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                //包装规格列表暂时不要，直接跳扫码界面
                //ARouterManagerUtils.gotoDailyInventoryListActivity(mContext)
                //包装规格
                val chooseModel = PackSpecsTypeModel()
                uhfDailyInventoryLauncher.launch(chooseModel)
            })
    }
}